package com.yinhe.music.yhmusic.collect;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.yinhe.music.yhmusic.R;
import com.yinhe.music.yhmusic.adapter.TabAdapter;
import com.yinhe.music.yhmusic.album.list.AlbumFragment;
import com.yinhe.music.yhmusic.base.BasePresenter;
import com.yinhe.music.yhmusic.base.BaseServiceActivity;
import com.yinhe.music.yhmusic.constants.IConstants;
import com.yinhe.music.yhmusic.singer.list.SingerListFragment;
import com.yinhe.music.yhmusic.utils.ViewUtils;
import com.yinhe.music.yhmusic.video.list.MvFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

import static com.yinhe.music.yhmusic.constants.IConstants.FAV_ALBUM;
import static com.yinhe.music.yhmusic.constants.IConstants.FAV_MV;

/**
 * @author 何晓华
 * @date 2017/9/22
 */

public class MyCollectionActivity extends BaseServiceActivity {
    @BindView(R.id.tabs)
    TabLayout tabs;
    @BindView(R.id.viewpager)
    ViewPager viewPager;

    private String[] title = {"歌手", "专辑", "MV"};

    @Override
    public void initView() {
        setToolbar("我的收藏");
        showQuickControl(true);

        setTab();
        setupViewPager(viewPager);
    }

    @Override
    public int getLayoutResId() {
        return R.layout.fragment_mv;
    }

    @Override
    public BasePresenter getPresenter() {
        return null;
    }

    @Override
    public void initPresenter() {

    }

    private void setTab() {
        ViewUtils.reflexIndicator(tabs, 50);
        tabs.setSelectedTabIndicatorColor(getResources().getColor(R.color.tab_color));
        tabs.setupWithViewPager(viewPager);
    }

    private void setupViewPager(ViewPager viewPager) {
        List<Fragment> fragmentList = new ArrayList<>();

        fragmentList.add(SingerListFragment.newInstance(IConstants.FOLLOW_LIST, null));
        fragmentList.add(AlbumFragment.newInstance(FAV_ALBUM, 0, null));
        fragmentList.add(MvFragment.newInstance(FAV_MV, "collection"));
        viewPager.setAdapter(new TabAdapter(getSupportFragmentManager(), fragmentList, title));
    }
}
